<!DOCTYPE html>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/common.jspf"%>
<%@ include file="/common/taglibs.jspf"%>
<html lang="en">
<head>
<!-- jquery datatables -->
<link href="${contextPath}/static/widgets/jquery-datatables/css/jquery.dataTables.css" rel="stylesheet" />
<script src="${contextPath }/static/widgets/jquery-datatables/js/jquery.dataTables.min.js"></script>
<script src="${contextPath }/static/widgets/jquery-datatables/js/jquery.dataTables.bootstrap.js"></script>
</head>
<body>
	<!-- quick view -->
	<h:quickview moduleCode="tenant"></h:quickview>
	<!-- toolbar -->
	<div class="toolbar">
		<button class="btn btn-small btn-primary" onclick="javascript:location.href='priceTable.do'">
			<i class="icon-plus icon-white"></i>
			<s:message code="btn.add" />
		</button>
		<button type="button" class="btn btn-small" onclick="javascript:$.quickview.switchFilter();">
			<i class="icon-search"></i>&nbsp;
			<s:message code='btn.query' />
		</button>
		<button type="button" class="btn btn-small" onclick="javascript:export_();">
			<i class="icon-inbox-out"></i>&nbsp;
			<s:message code='btn.export' />
		</button>
		<div class="btn-group">
			<a class="btn btn-small dropdown-toggle" data-toggle="dropdown" href="#"><s:message code="btn.moreAction" /> <span class="caret"></span></a>
			<ul class="dropdown-menu">
				<li><a href="#" style="color: green" onclick="javascript:batchNormal();return false;"><i class="icon-email"></i> <s:message code="tenant.func.normalBatch" /></a></li>
				<li><a href="#" onclick="javascript:batchDisable();return false;"><i class="icon-email"></i> <s:message code="tenant.func.disabledBatch" /></a></li>
				<li><a href="#" style="color: red;" onclick="javascript:batchDelete();return false;"><i class="icon-trash"></i> <s:message code="btn.deleteBatch" /></a></li>
			</ul>
		</div>
	</div>
	<div class="clear"></div>
	<h:quickview-filter search="${quickviewConfig.search }"></h:quickview-filter>
	<!-- datatable -->
	<div>
		<h:quickview-grid table="${table }" var="row">
			<div class="action-buttons">
				<a href="conf.do?id=${row.ID }" class="blue" title=<s:message code="tenant.func.conf" />> <i class="fa fa-cog"></i></a>&nbsp; 
				<a href="tenantOrder.do?id=${row.ID }" class="blue" title=<s:message code="tenant.func.order" />> <i class="fa fa-shopping-cart"></i></a>&nbsp; 
				<a href="confTenantMember.do?id=${row.ID }" class="blue" title=<s:message code="tenant.func.confTenantMember" />><i class="fa fa-group"></i></a>&nbsp;
				<c:choose>
					<c:when test="${row.STATUS == 1 }">
						<a href="javascript:;" onclick="disabled(${row.ID});" title=<s:message code="tenant.func.lock" />> <i class="fa fa-ban"></i></a>&nbsp;
           				<a href="javascript:;" class="red" onclick="rowDelete(${row.ID});" title=<s:message code="tenant.func.delete" />> <i class="fa fa-trash"></i></a>
					</c:when>
					<c:otherwise>
						<a href="javascript:;" class="green" onclick="beNormal(${row.ID});" title=<s:message code="tenant.func.unlock" />> <i class="fa fa-check"></i></a>
					</c:otherwise>
				</c:choose>
			</div>
		</h:quickview-grid>
		<h:pager params="${requestScope[table.dataset] }" formId="datatable"></h:pager>
	</div>

	<!--page specific plugin scripts-->
	<script type="text/javascript">
		$(document).ready(function(){				
			$('.datatable').dataTable();

			
			var checkboxs = $.webtools.checkboxs({
				checkAll: "#checkAll",
				checkItem: ".checkItem"				
			});
		})		
		
		function batchDelete(){					
			if($(".checkItem:checked").length<=0)
			{
				$.webtools.notify({
					type: "notice",
					message: "<s:message code='validate.checkone'/>"
				});
				return;
			}
			var ids = $.webtools.getCheckValuesArray(".checkItem");	
		
			bootbox.confirm("<s:message code='common.delete.confirm' />", function(result){
				if(result)
				{
					$.webtools.ajax({
						url: "deleteBatch.json",
						params: {"ids":ids},
						success: function(reply) {
							location.reload();
						}
					});						
				}				
			});		
		}	
		
		function batchNormal(){					
			if($(".checkItem:checked").length<=0)
			{
				$.webtools.notify({
					type: "notice",
					message: "<s:message code='validate.checkone'/>"
				});
				return;
			}
			var ids = $.webtools.getCheckValuesArray(".checkItem");	
		
			bootbox.confirm("<s:message code='tenant.normal.confirm' />", function(result){
				if(result)
				{
					$.webtools.ajax({
						url: "normalBatch.json",
						params: {"ids":ids},
						success: function(reply) {
							location.reload();
						}
					});						
				}				
			});		
		}	
		
		
		function batchDisable(){					
			if($(".checkItem:checked").length<=0)
			{
				$.webtools.notify({
					type: "notice",
					message: "<s:message code='validate.checkone'/>"
				});
				return;
			}
			var ids = $.webtools.getCheckValuesArray(".checkItem");	
		
			bootbox.confirm("<s:message code='tenant.disabled.confirm' />", function(result){
				if(result)
				{
					$.webtools.ajax({
						url: "disableBatch.json",
						params: {"ids":ids},
						success: function(reply) {
							location.reload();
						}
					});						
				}				
			});		
		}	
		
		
		function rowDelete(id){			
			bootbox.confirm("<s:message code='common.delete.confirm' />", function(result){
				if(result)
				{
					$.webtools.ajax({
						url: "delete.json",
						params: {"id":id},
						success: function(reply) {
							location.reload();
						}
					});					
				}				
			});			
		}	
		
		
		function disabled(id){			
			bootbox.confirm("<s:message code='tenant.disabled.confirm' />", function(result){
				if(result)
				{
					$.webtools.ajax({
						url: "disabled.json",
						params: {"id":id},
						success: function(reply) {
							location.reload();
						}
					});					
				}				
			});			
		}		
		
		
		function beNormal(id){			
			bootbox.confirm("<s:message code='tenant.normal.confirm' />", function(result){
				if(result)
				{
					$.webtools.ajax({
						url: "beNormal.json",
						params: {"id":id},
						success: function(reply) {
							location.reload();
						}
					});					
				}				
			});			
		}	
		
		function export_(){
			alert('敬请期待...');
		}
	</script>
</body>
</html>
